<?php

include_once ('bn_path.php');

class bn_hookfunc
{
    protected static $instance;

    public static function getInstance()
    {
        if (!isset(self::$instance))
        {
            self::$instance = new self();
        }
        return self::$instance;
    }

    private $hook = array();

    public function __set($name, $funcname)
    {
        $this->hook[$name] = $funcname;
    }

    public function __get($name)
    {
        return $this->hook[$name];
    }

    public function call_functions()
    {
        foreach ($this->hook as $func)
        {
            if (function_exists($func))
                call_user_func($func);
        }
    }

    public function call_function($name, $args = array())
    {
        if (function_exists($this->hook[$name]))
        {
            if (empty($args))
                return call_user_func($this->hook[$name]);
            else
                return call_user_func_array($this->hook[$name], $args);
        } else
            return 0;
    }
}

?>